function [Dstates,Dactions,DnextState,gameState] = collectExperience(net,gameState,Dstates,Dactions,DnextState,numberOfTransitions,view_data)
%COLLECTEXPERIENCE Summary of this function goes here
%   Detailed explanation goes here

ids = randi(size(Dactions,2),numberOfTransitions,1);

if(isempty(gameState))
    gameState = resetGame();
end
for i=1:numberOfTransitions
    if view_data>0
        displayState(gameState);
        gameState.cleared
        pause(0.01)
    end
    qState = gameStateToQState(gameState);
    action = getEpsilonGreedyAction(net,qState,0.1);
    gameState = forwardSimulate(gameState,action);
    qNextState = gameStateToQState(gameState);
    Dstates(:,ids(i)) = qState;
    Dactions(:,ids(i)) = action;
    DnextState(:,ids(i)) = qNextState;
    if checkDeath(gameState)
        display('Died');
        display(gameState.cleared); 
        gameState = resetGame();
        break;        
    end    
end
end